For displaying three-dimensional representations of objects on a display screen, graphics-processing systems typically partition each object into geometric primitives. Geometric primitives are elementary graphics building blocks, examples of which include points, lines, images, bitmaps, vectors, and polygons. Triangles are a commonly employed form of primitives. Each primitive is stored as a set of vertices, with each vertex having associated display parameters, including color parameters, display (or pixel) location parameters, and texture parameters. Each primitive passes through a graphics pipeline. A rasterizer identifies the pixels corresponding to each primitive.
Three-dimensional scenes can have numerous objects, with many of the objects having thousands of primitives; thus, the rendering process is generally computationally intensive and complex. Often, a 3-D scene has overlapping objects. Depending upon the extent of overlap, opaque objects in the foreground can occlude a portion of or all of an object in the background. Thus, such objects may be invisible. Accordingly, an important part of the 3D rendering process is the use of depth (i.e., Z) information.
Some graphics-processing systems determine which objects are visible at a late stage in the graphics pipeline, often after determining texture and color information for the pixels. The graphics processor then discards the pixel information for the occluded object. Computing pixel information for an invisible object, therefore, is an inefficient use of processing power and unnecessarily prolongs the rendering process.
As a mechanism to reduce unnecessary computations during the 3D rendering process, graphics processing systems employ a hierarchical Z-buffering technique before rendering a pixel. The hierarchical Z-buffering technique (referred to herein as Hi-Z) entails comparing the Z values of pixels at the same (x, y) display location with a stored Z value for that location. The stored Z value represents the pixel presently deemed closest to the viewer. Pixels with a lesser Z value than the stored Z value are occluded, and are not rendered. A new pixel with a Z value that is higher than the stored Z value, however, becomes the closest (i.e., visible) pixel and is therefore rendered. In addition, and update to the Hi-Z buffer stores this new Z value to reflect the new closest pixel.
To reduce the computational load to determine possible occlusions prior to rendering, Hi-Z determinations can operate on tiles (i.e., a matrix of multiple pixels). Early Hi-Z techniques stored a far Z value for each tile. For a given incoming geometry, it could then be determined whether that a near-Z value of the geometry will fail a depth test when compared to the stored far Z value of the tile. The comparison served primarily to reject (i.e., cull) pixels that would not be drawn, thereby avoiding the inefficient process of rendering a pixel only to be later discarded.
Another means by which a pixel may be occluded is through stenciling. Similar to background pixels occluded by foreground objects, rendering pixels occluded by a stencil is wasteful. In one typical use, a stencil is a mask placed on the output scene that produces a shadow in accordance with the location of a light source. The stencil occludes pixels at the same x, y location with a smaller Z value than the stencil, i.e., it falls within the shadow. A pixel thus covered by the stencil is invisible (i.e., hidden in the shadow) and is not rendered. Shadow volumes are but one of many different exemplary uses for stencil. As an enhancement to the process of identifying stencil-occluded pixels, graphics processing systems can employ a hierarchical stencil technique that, like Hi-Z, operates on tiles of pixels. Hi-S can provide an early indication of whether the tile will pass (be rendered), will fail (be culled), or whether the outcome is unknown.